package cn.iocoder.yudao.framework.region.vo;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.region.RegionUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  使用 Lombok 时需注意标记上 {@code @Accessors(chain = false)}
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2024/11/28
 */
@Schema(description = "地址信息 VO")
@Data
public class AddressVO extends CountyVO {

    @Schema(description = "省市区县", deprecated = true, example = "贵州省贵阳市南明区")
    private String provinceCityCounty = "";

    /**
     * @deprecated 请使用 {@link #getProvinceName()}/{@link #getCityName()}/{@link #getCountyName()} 代替
     */
    @SuppressWarnings("unused")
    @Deprecated
    public String getProvinceCityCounty() {
        if (StrUtil.isBlank(provinceCityCounty)) {
            return RegionUtils.formatDetailAddress(getProvinceName(), getCityName(), getCountyName(), "");
        }
        return provinceCityCounty;
    }

    @Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "花果园金融街5号驰通集团公司")
    private String detailAddress = "";

    @SuppressWarnings("unused")
    public String getDetailAddress() {
        return RegionUtils.formatDetailAddress(getProvinceName(), getCityName(), getCountyName(), detailAddress);
    }

    @Schema(description = "纬度", example = "106.690801")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Double latitude;

    @Schema(description = "经度", example = "26.567322")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Double longitude;

    @Schema(description = "完整地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "贵州省贵阳市南明区花果园金融街5号驰通集团公司")
    private String fullAddress = "";

    @SuppressWarnings("unused")
    public String getFullAddress() {
        if (StrUtil.isBlank(fullAddress)) {
            return RegionUtils.formatFullAddress(getProvinceName(), getCityName(), getCountyName(), getDetailAddress());
        }
        return fullAddress;
    }

}
